<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="author" content="wangbo">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>事件</title>
</head>
<body>
  <!-- 内联式 -->
  <div onclick="myclick(event)" >内联式</div>
  <div id="div1"  >动态绑定</div>
  <div id="div2"  >事件监听</div>
  <a href="#"  ></a>
  <script>
    function myclick(event) {
      console.log("点击事件",event)
    }
    // 直接接受event
    let myclick2 = function (event) {
      console.log("动态绑定",event)
    }
    let myclick3 = (event) => {
      console.log("事件监听",event)
    }
    let a= 10;
    let div1 = document.querySelector("#div1")
    // 函数传递
    div1.onclick = myclick2
    let div2 = document.getElementById("div2")
    div2.addEventListener("click",myclick3)
  </script>
</body>
</html>